<template>
	<mescroll-uni :ref="'mescrollRef'+tabIndex" @init="mescrollInit"   @down="downCallback" @up="upCallback">
		<view class="u-padding-left-32 u-padding-right-32 swiper-box-padding" v-if="dataList.length">
			<view  v-for="(item,index) in dataList" :key="index" class="u-margin-top-20" @click="goPathDetail(item)">
				<list-item :item="item" :showStar="false" :showFooterRight="false" :isShare="false" height="347">
					<view slot="content" class="cur-content">
						<!-- <view class="u-font-20 text-color-B0B2D8 u-padding-top-20">
							开放加入时间:{{item.enrollTime}}
						</view> -->
						<view class="u-flex u-margin-top-6">
							<flex-text txt="游戏开始时间" size="24" width="145" customClass="content-desc-item"></flex-text>
							<text class="u-font-24 content-desc-item">：{{item.estimateTime | timeFormat}}</text>
						</view>
						<view class="u-flex u-margin-top-6" v-if="item.completeTime">
							<flex-text txt="结束时间" size="24" width="145" customClass="content-desc-item"></flex-text>
							<text class="u-font-24 content-desc-item">：{{item.completeTime | timeFormat}}</text>
						</view>
						<!-- 玩家 -->
						<!-- <view class="u-margin-top-24" v-if="item.userSmallDtos && item.userSmallDtos.length>0">
							<avatar-list :totalNumber="item.people" :userList="item.userSmallDtos"></avatar-list>
						</view> -->
					</view>
					<view slot="footer-end" >
						<view class="u-flex u-row-right u-margin-top-15">
							<view class="u-font-30 u-flex-1 u-text-right">
								<text class="text-color-txtTheme">{{item.participate}}</text>/{{item.people}}人
							</view>
							<view class="u-padding-left-30 box-title text-bold">
								<text v-if="item.status==0">组局中</text>
								<text v-if="item.status==1">游戏中</text>
								<view v-if="item.status==2" class="u-flex">
									<u-icon name="checkmark-circle-fill" :color="currentThemeObj.primary" size="24" v-if="item.status==2"></u-icon>
									<text class="u-margin-left-12">已完成</text>
								</view>
							</view>
						</view>
					</view>
				</list-item>
			</view>
			
		</view>
		<model v-model="modelFlag" :show-title="false" :show-cancel-button="modelType!=='rejectFlag'" :show-confirm-button="modelType!='confirmCar'" cancel-color="#333333" :confirm-color="currentThemeObj.primary" :content="closeModalTips" @confirm="confirmClose" @cancel="clearTime"/>
	</mescroll-uni>
</template>

<script>
	import upCallback from '@/mixins/upCallbackMixin.js'
	import gameManager from '@/mixins/gameManager.js'
	import model from '@/components/u-modal/u-modal.vue'
	export default {
		mixins: [upCallback,gameManager], // 注意此处还需使用MescrollMoreItemMixin (必须写在MescrollMixin后面)
		props:{
			tab:{
				type:Object,
				default:()=>({})
			},
			tabIndex:{
				type:Number,
				default:0
			},
			inputName:{
				type:String,
				default:''
			},
		},
		components: {
			model
		},
		
		data() {
			return {
				apiType:"gatherGame",
				apiModule:'shopApi',
				name:'thirdQuery',
				modelFlag:false,
				form:{},
				goon:{
					backgroundColor:'#765CFE',
					borderColor:'none',
					width:'143rpx'
				},
				goonDis: {
					backgroundColor:'rgba(118,92,254,0.4)',
					borderColor:'none',
					width:'143rpx'
				},
			}
		},
		computed: {
			isStore() {
				return 'store'===this.isAuth
			},
			isAuth(){
				const loginForm = this.loginForm;
				return loginForm&&loginForm.userType || 'store'
			}
		},
		created() {
			const {type,showEnrollTime} = this.tab;
			this.form = {type,status:type,showEnrollTime,storeId:this.loginForm.storeId}
		},
		methods: {
			goPathDetail(item){
				this.$u.route({
					url:'/pagesA/storeAddLarp/detail',
					params:{
						id:item.id
					}
				})
			},
			//评测
			reply(item){
				if(item.isEvaluation) return false;
				this.$u.route({url:'/pagesA/userSubmit/userSubmit',params:{
					type:"settingTest",
					productId:item.productId,
					id:item.id
				}})
			},
			//意向
			want(item){
				if(item.isSubmitIntention) return false;
				this.$u.route({url:'/pagesA/want/setting',params:{
					productId:item.productId,
					driveCarId:item.id
				}})
			},
			cancelCarcallback(res){
				this.dataList = this.dataList.filter(val=>val.id!==res.id);
				if(this.dataList.length===0){
					this.downCallback()
				}
			},
			//发车回调
			startCarcallback(res){
				this.cancelCarcallback(res)
			},
			selectCallback(){
				this.downCallback()
			},
			//上车回调
			intoCar(item){
				this.sort()
				this.goPathDetail(item)
			},
			//排序
			sort(){
				this.dataList.sort(a=>a.isIntoCar?-1:1)
			},
			userList(item){
				this.$u.route({
					url:'/pagesA/carUserList/carUserList',
					params:{
						id:item.id,
						gatherGamedId:item.id,
						name:'findGatherGameUserSmallDto',
						type:'gatherGame'
					}
				})
			},
			timeout(item){
				const nowTime = new Date().getTime();
				const time = new Date(item.enrollTime).getTime();
				return nowTime > time;
			},
			//跳转到倒计时页面
			carTime(item){
				this.$u.route({
					url:'/pagesA/carTime/gameTime',
					params:{
						id:item.id
					}
				})
			}
		}
	}
</script>

<style>
.cur-content{
	height: 100rpx;
}
</style>
